package vn.com.epi.data.table;

import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.util.Bytes;

public class UserTable {
    
    public static final String NAME = "User";
    public static final String COLD_START = "cold start problem";
    public static final  byte[] NAME_BYTES = Bytes.toBytes("User");
    public static final byte[] FAM_MAIN = Bytes.toBytes("main");
    public static final byte[] COL_VISITED_TIMESTAMPS = Bytes.toBytes("visitedTimestamps");
    public static final byte[] COL_VISITED_ARTICLES = Bytes.toBytes("visitedArticleIds");
        
    public UserTable() {     
        
    }
    
    public static String getVisitedTimestamps(Result result) {
        try {
            String timestamps = Bytes.toString(result.getValue(FAM_MAIN, COL_VISITED_TIMESTAMPS));
            if (timestamps == null)
                timestamps = "";
            return timestamps;
        } catch (Exception e) {
            return "";
        }
    }
    
    public static String getVisitedArticles(Result result) {
        try {
            String articles = Bytes.toString(result.getValue(FAM_MAIN, COL_VISITED_ARTICLES));
            if (articles == null)
                articles = "";
            return articles;
        } catch (Exception e) {
            return "";
        }        
    }
    
}
